/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bsc.ejb.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;

/**
 *
 * @author memozac
 */
@Entity
public class Tracer implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long idTracer;
    
    public enum Type{PROGRESS,BUDGET};

    @Enumerated
    private Type type;

    @Column(columnDefinition="text")
    private String name;
    
    private Double percentFactor;

    @ManyToOne
    private Project project;

    @ManyToMany(targetEntity=Milestone.class)
    @JoinTable(name="MilestoneTracer",
    joinColumns=@JoinColumn(name="idTracer"),
    inverseJoinColumns=@JoinColumn(name="idTask"))
    private Collection<Milestone> milestones;

    public Long getIdTracer() {
        return idTracer;
    }

    public Project getProject() {
        return project;
    }

    public void setProject(Project project) {
        this.project = project;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public void setIdTracer(Long idTracer) {
        this.idTracer = idTracer;
    }

    public Collection<Milestone> getMilestones() {
        return milestones;
    }

    public void setMilestones(Collection<Milestone> milestones) {
        this.milestones = milestones;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getPercentFactor() {
        return percentFactor;
    }

    public void setPercentFactor(Double percentFactor) {
        this.percentFactor = percentFactor;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTracer != null ? idTracer.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Tracer)) {
            return false;
        }
        Tracer other = (Tracer) object;
        if ((this.idTracer == null && other.idTracer != null) || (this.idTracer != null && !this.idTracer.equals(other.idTracer))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "bsc.ejb.entity.Tracer[id=" + idTracer + "]";
    }
}//ends of class
